Megaman - The Wily Wars hacking notes
ooooooooooooooooooooooooooooooooooooo
Written June 2010 by Matrixz

These notes were written based on the European BIN rom.
I'm not sure if the offsets are at different locations in the
roms for other regions.

Hacking

~

If you modify one byte of this rom from its original form,
it will show a red screen of death upon boot. Even if you use a
tool to fix the checksum or make your emulator fix the checksum,
it will still give the same result.

One way to get past this is to download the European rom, and
apply the "SRAM Save Hack" IPS patch by MottZilla.
It will make it possible to save games properly, and it will
also patch the checksum code so you may hack without
getting the red screen.

The IPS patch can be found on romhacking.net here:
http://www.romhacking.net/hacks/514/

Notation

~

" ~ " is used when the pointers are approximate, but not precise.

Graphics compression

~

It seems some graphics in the game are compressed and some are not.
You can determine this in-game for a level by the time passing between the boss
demo fades out and the level fades in. If it fades in immediatedly,
(example: Air Man and Gemini Man stages) that level's graphics are not compressed.
It may be related to tile animations being used in the level.

Music hacking notes

~

It is possible to somewhat port music from other Genesis games
to others. The music format is referred to as SMPS and comes in some
slighly varied formats through games.

This is a great guide to Genesis music hacking in general:
http://info.sonicretro.org/SCHG:Music_Hacking

It seems that SMPS files in MMWW is limited to $903 bytes in size.
Anything more and it will overwrite other memory used by the Z80
proccessor.

Music data:

byte 0-1: Size of music data, in Big-Endian byte order.
byte 2-3: Start of music inside Z80 memory.
byte 4-> : SMPS data

Offsets

~

0-1FF : Header

200 - ~642DD : Might be all the programming in the game. Same pattern of bytes until 642DE.

65872-> : Music track selection for levels and boss battles
	65872 : Megaman 1 - Music track for levels
	65886 : Megaman 2 - Music track for levels
	6589A : Megaman 3 - Music track for levels

	658B8-> : Music for boss battles

	(note: You can have different music for each individual boss.)

Weapon menu layouts:

	Each word represents an entry in the weapon menus.

	659C2 : Weapon Menu Layout - MM2

	65A50 : Weapon Menu Layout - MM3

	I couldn't find the one for MM1 yet.

	Weapon menu layout values: 
	
	00 : Buster
	..
	04 : Ice Slasher
	05 : Rolling Cutter
	06 : Fire Storm
	07 : Magnet Beam
	08 : Atomic Fire
	..
	18 : Top Spin
	19 : Search Snake
	1A : Spark Shot
	1B : Shadow Blade
	1C : Rush Coil
	1D : Rush Marine
	1E : Rush Jet

~66320 : Text

~6A650 : End of text datas

6E348-6E493 : Music data pointers

6E53x-6EC00 : Enemy HP, damage to Megaman, and damage properties from weapons.

	Properties in chunks of 0x1C bytes, one for each enemy. 

	Those flying enemies in the start of Cutman's stage:
	6E568 : Some property (HP)
		Value:
		0: they die upon initialization
	6E569 : Damage/effect on megaman upon collision
		Value:
		0xFE: Megaman's HP is increased by 1
	6E56A : Buster damage
		Value:
		
		0x0 - 0x7F : Damage to enemy
		
		Special values:
		0x81 : Buster flies through
		0x82 : Buster deflected
		0x83 : Immediate kill?
		0x84 : Temporarily freeze enemy in its movement (Ice Slasher effect?)
		0x85 : Temporarily freeze enemy in its movement (Flash Stopper effect?)
		0x86 : Buster flies through
		0x87 : Undefeatable (hit by buster but never dies)
	6E56B : Probably same kind of byte as previous, for all other weapons.

	6E894 : Properties for MM1 big blocks (lifted by Super Arm)

707F8 : MM1 scores given when defeating enemies (Values in word size)

~70AA2 : MM1 Weapon Menu tile layout somewhere in here

76B02 : Some data

779C4 : Level Enemy Layout pointers

	7981A : Woodman Enemy Layout
	There is a pointer for each screen in the level.
	
	7987C : Enemy layout for 2nd screen of Woodman's level.

	Enemy layout format:
	Each enemy entry uses 8 bytes for its information.
	When there is no more enemies for the actual screen, the
	data ends with two zeroed bytes (0000).

	byte 0: Enemy index of level
	byte 1: Enemy ID or Item ID (See "Enemy IDs")
		(if this is 00, there are no more enemies on that screen and bytes 2-7 does not exist.)
	byte 2: X location
	byte 3: Y location
	byte 4: Extra info (Mirror) (usually 0)
		MSB
		bit 6: Set : Enemy is vertically mirrored on init
		bit 7: Set : Enemy is horizontally mirrored on init
		LSB
	byte 5: Boss init flag (usually 0)
		Must be 0x01 for bosses to start attacking. Otherwise they
		will act like in the boss demo.
	byte 6: Extra info (Hatch door?) (usually 0)
	byte 7: Extra info (Effect) (usually 0)
		Value:
		02: Sprite is an Item
		03: Slight delay before appearance
		13: Enemy is transformed (uses item graphics, behaviour changes)
		53: Megaman can't move (for a while)

7F37C-808DB : Graphics : Bullet, Health bar, Misc.

855B2-872FF : Blank (free?) space

8870E-E3xxx : Sprite graphics mixed with sprite grouping and hit detection data.

	Megaman 2 Crabbot enemy:
	9FD66 : Pointer to 9FD7E
	9FD6A : Pointer to 9FD8E
	9FD6E : Pointer to 9FD9E
	9FD72 : ???
	9FD76 : Pointer to 9FDB8
	9FD7E-> : Hit detection and sprite grouping
	9FDD8 : Pointer to graphics (9FDDC)
	9FDDC : Uncompressed graphics

E4000 - ~FF790 : Megaman 1 - level datas

100000 : Level pointers

100000 : Megaman 1 Level Pointers

100280-100043F : Megaman 2 - Level Pointers
	1002C0 : Pointer to Quickman Map
	1002C4 : Pointer to Quickman Screen Pointers
	1002C8 : Pointer to Quickman TSA
	1002CC : Pointer to Quickman TSA properties
	1002D0 : Pointer to Quickman Map coordinates
	1002D4 : Pointer to ?? (graphics related)
	1002E0 : Pointer to Heatman Map
	...

100500 : Megaman 3 Level Pointers
100780 : Wily Tower Level Pointers
100A00 : Other screen pointers (all game modes)

Format:

Each level is divided into 32 bytes containing 7 pointers
and 4 additional bytes.

0 : Pointer to Map (See "Map data format")
4 : Pointer to Screen Data pointers
8 : Pointer to TSA
C : Pointer to TSA Properties
10 : Pointer to Map Coordinates for Starting point and Continue points.
14 : Pointer to Graphics (Can be both compressed and uncomressed?)
18 : ? Function unknown. (not a pointer)
1C : Pointer to Level background data

10A000 - ~137BB8 : Megaman 2 - level datas

10EDAE : ??

Quickman level data:
	112900 : TSA
	113172 : TSA property
	113272 : Map Height/Width
	113276 : Map matrix data
	113396 : Map coordinate for Starting point
	113398 : Map coordinate for Middle Continue point
	11339A : Map coordinate for Boss continue point
	11339C : 4th, optional continue point?
	11339E : Screen data pointers
	11498E : Compressed graphics

1DCxxx : End of level datas?

1DC480 : Graphics (ending?)

1E0C00 : Palette Pointers
	1E0C28 : Cutman level palette pointer

1E16C4 : Cutman level palette

1E4000 : Sound effect data?

1E5FCC : Music Data (Cutman)
1FEDE4 : Last Music Data

1FF100-1FFFFF: Capcom Logo Graphics


~

Map data format:

The map is a matrix with a defined width and height.
The level can start anywhere in the map. Levels can be scrolled
in the left direction. It is also possible to create branches
and loops in the level's path.
The two first words in the map data tells the Width and Height, respectively.
From there follows a word for each screen in the matrix.
For screens that are not used, the value is set to be FFFF.

Map word format:

Byte 0:
	(+ means to add that value)
	+ 0x1 : Belongs to 2nd part of level?
	+ 0x2 : Belongs to 3rd part of level?
	+ 0x3 : Belongs to 4th part of level?
	+ 0x8 : Implies boss chamber hatch?
	+ 0x10 : Right scrolling enabled
	+ 0x20 : Left scrolling enabled
	+ 0x40 : Vertical scrolling enabled (Down? Not needed?)
	+ 0x80 : Vertical scrolling enabled (Up? Not needed?)

Byte 1: Level screen

At the end, there is 4 words for each continue point in the level.
The 1st is the starting point in the level.
It seems that there can be a 4th continue point.
Each word tells the coordinate for that point into the matrix.

~

Enemy IDs:

01 : Metool (MM1?)
..
08 : Suzy
..
10 : ??
..
14 : Iceman
15 : Bombman
18 : Cutman
19 : Gutsman
1A : Yellow Devil
..
1C : Metool (static) (MM2?)
..
20 : Elecman stage spark (horizontal)
..
28 : Pipi
..
30 : Press
..
38 : Atomic chicken
..
40 : Big fish
41 : Airman
42 : Crashman
43 : Metalman
44 : Woodman
45 : Flashman
46 : Quickman
47 : Bubbleman
48 : Heatman
..
50 : Hammer Joe
..
58 : Top Fiend
..
60 : Metool
..
68 : Damaging object (unk)
69 : Sparky
..
70 : Nitron
..
78 : Sparkman
79 : Shadowman
7A : Needleman
..
80 : Wily Machine (MM3)
..
84 : Randomly appearing block(s)
..
88 : Platform (MM2?)
..
90 : Splitting platform
..
98 : Quickman laser
..
A0 : ??
..
A8 : Doc Robot (sprite only?)
..
B0 : Metool
..
B8 : Buster Rod G
B9 : Mega Water S

~

Item IDs:

01: Smal health

~